ggml-vulkan/CMakeLists: add a check for SPIRV-Headers#22009
ggml-vulkan/CMakeLists: add a check for SPIRV-Headers#22009jeeb wants to merge 2 commits intoggml-org:masterfrom
Conversation
67ceea6 to
17f341b
Compare
17f341b to
99ee286
Compare
|
My main desktop has nicely started showing signs of degradation right after I made this PR, but I am still alive, and the main reason for this change is still around: Fail during configure step and not after XY files (hundreds in the best case) have already been compiled. This works for both Linux (tested on Fedora and as far as I can tell Ubuntu has a very similar file listing for its related package) and cross-compilation to Windows from Linux (as long as SPIRV-Headers is installed via their cmake build system - it installs the files mentioned). The only questions would be the Windows Vulkan SDK and NDK (if thought as a valid Vulkan target). I expect MoltenVK to not be a target for llama.cpp, as native Metal back-end seems to exist. It would be nice if the CI flow could be enabled, so these could be checked. I saw under |
|
Ah, so MoltenVK indeed was a target - as that is the first thing to fail. Will check how that sysroot is handled. edit: seems like the dependencies are not installed by the CI flow? ggml-ci-mac-vulkan:
runs-on: [self-hosted, macOS, ARM64]
steps:
- name: Clone
id: checkout
uses: actions/checkout@v6
- name: Test
id: ggml-ci
run: |
vulkaninfo --summary
GG_BUILD_VULKAN=1 bash ./ci/run.sh ~/results/llama.cpp ~/mnt/llama.cppWill have to check how and what the MoltenVK SDK (if that is what is being installed onto the system) contains. Funnily enough the configure part of Windows + Vulkan CI flow seems to pass JustFine (https://github.com/ggml-org/llama.cpp/actions/runs/25050050776/job/73380477706?pr=22009#step:8:70) edit2: Checked MoltenVK's SDK contents (https://github.com/KhronosGroup/MoltenVK/releases/tag/v1.4.1) and neither So I guess SPIRV-Headers was installed manually on this runner? |
|
Alright, grabbed my old Intel Macbook and grabbed the latest Vulkan SDK from LunarG (trying to look at MoltenVK SDK was a mistake - got things confused) find VulkanSDK/1.4.341.1/macOS -iname 'spirv-headers*'
# VulkanSDK/1.4.341.1/macOS/lib/pkgconfig/SPIRV-Headers.pc
# VulkanSDK/1.4.341.1/macOS/lib/cmake/SPIRV-Headers
# VulkanSDK/1.4.341.1/macOS/lib/cmake/SPIRV-Headers/SPIRV-HeadersConfig.cmake
# VulkanSDK/1.4.341.1/macOS/lib/cmake/SPIRV-Headers/SPIRV-HeadersConfigVersion.cmakeSo the necessary files are included. Then tested building this PR's branch and found out that it works as long as cmake is being told where to look ( The result compiles fine. So I guess I can spy where Vulkan is found on the previous macOS Vulkan build runs, and see if I can make cmake search for things in its sysroot. edit: So if this is properly packaged, |
99ee286 to
47b3bc9
Compare
This allows for SPIRV-Headers to be found, as currently the CI runner's setup does not seem to include the relevant path in list of search locations. We could set this globally across all darwin builds, but for now limit to Vulkan.
This is installed by the project if it is built and installed. Receiving an error during the configuration step is generally preferred to receiving an error in the middle of a build.
47b3bc9 to
830d8dd
Compare
|
Two alternative takes on this would be:
|
|
When you use the SDK, you're supposed to source its setup-env file. If you've done that, cmake should find it with no manual configuration. |
Thanks for the information. I was just in general wanting to verify whether building with what I expect is going to be utilized by people would work. Do you happen to know whether this setup-env script is there on the macOS runner utilized for the Vulkan build? If yes, we can source that in the CI script ( |
Overview
This makes the build fail at configure time instead of build time in case any of the sysroots included does not contain SPIRV-Headers. Generally it is preferred to fail as quickly as possible if a required dependency is not available.
Files related to this package are installed as part of the SPIRV-Headers project (both cmake files as well as a pkg-config file).
I have verified this with cross-compilation from Linux to Windows as that is what I'm mostly poking at right now. I expect this to also work on Linux as at least Fedora (spirv-headers-devel) and Ubuntu (spirv-headers) package these files. I tried to check whether these files are contained within the LunarG Windows Vulkan SDK package, but at least
vulkansdk-windows-X64-1.4.341.0.exeandvulkansdk-windows-X64-1.4.341.1.exeonly seem to contain theBindirectory inside and no clear extractable archives :/ .If this check fails with the Windows Vulkan SDK (this should be check'able by the CI), then a compiler check with the exact header inclusion logic as in
ggml-vulkan.cppcan be done instead.Requirements